package com.bruce.starts.demo.test.threadlocal;

import java.util.concurrent.atomic.LongAdder;

public class A {
    private String name;
    private Integer seq;

    private static ThreadLocal<LongAdder> seqLocal = ThreadLocal.withInitial(()-> new LongAdder());

    public A(String name) {
        this.name = name;
    }

    public void checkAndBuild(){
        seqLocal.get().increment();
        setSeq(seqLocal.get().intValue());
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
